package com.fqdf.framework.android.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

/**
 * @author 张枭
 *         date 2017/4/6
 * @version V1.0
 */
public abstract class CommonViewPageAdapter<T> extends BaseViewPageAdapter<T> {
    private int mRes;

    public CommonViewPageAdapter(Context context, int res) {
        super(context);
        mRes = res;
    }

    @Override
    public Object instantiateItem(ViewGroup view, int position) {

        View v = getLayoutInflater().inflate(mRes, view, false);

        T item = getItem(position);
        convert(v, item);
        view.addView(v, 0);
        return v;
    }

    // 提供给外部填充实际的显示数据，以及可以一些其他的操作，如：隐藏＝＝
    public abstract void convert(View view, T item);

}
